<?php
require_once ("src/db/connectdatabase.php");

function getCompareLoans($id) {
	$con = new ConnectDB();
	
	$sql = "SELECT c.idcom, c.bankid, b.bankname, b.banklogo, c.idloanmaxi, c.amountloanmin, c.amountloanmax, c.salarypermounth, c.hinhthuctraluong, c.interrestrate, c.interrestrate2, c.typerate, c.timeloan, c.phitattoan, c.country, c.tttrchan, c.isbankphi, c.loanmaxxitext, c.conditionbasic FROM compareloanspersional AS c, banks AS b WHERE c.bankid=b.bankid AND c.idcom='".$id."'";
	return $con -> getvalueString($sql);
}

if(isset($_GET['id'])) {
	$idload = $_GET['id'];
	$arrload = getCompareLoans($idload);
	if(count($arrload) > 0) {
?>
<style>
.table-detail-compare td {
	height: 40px;
}
</style>
<div class="text12" style="margin: auto; width: 970px; height: 11px; margin-top: 11px; color: #0a8bd9;">
	<u><a href="<?php echo($host) ?>" class="text12" style="color: #0080d6;">Trang chủ</a></u>&gt; Chương trình vay
</div>
<div style="clear:both; height:15px;"></div>
<div class="intrl_txt" style="margin: auto;">
    <div style="float: left; width: 675px; margin-top: 20px; clear: right;">
        <div id="txt">
        	<table width="675px" border="0px" class="table-detail-compare" style="font-size: 12px;">
            	<tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Tổ chức</span></td>
                    <td align="center" width="470px"><img height="50px" title="<?php echo($arrload[0][2]) ?>(<?php echo($arrload[0][1]) ?>)" alt="<?php echo($arrload[0][2]) ?>" src="<?php echo($host) ?><?php echo($arrload[0][3]) ?>" /><td>
                </tr>
                <tr>
            		<td style="background: #F1F1F1;" align="left" width="200px"><span style="margin-left: 20px;">Khoản vay tối đa</span></td>
                    <td style="background: #F1F1F1;" align="center">
					<?php $stridloanmaxitemp = $arrload[0][4];// cot khoan vay toi da
					$arridloanmaxi = explode(',', $stridloanmaxitemp);
					$nametemp = "";
					for($j = 0; $j < count($arridloanmaxi); $j++) {
						if($arridloanmaxi[$j] == "1") $nametemp .= "Dưới 6 lần thu nhập. "; else $nametemp .= "Trên 6 lần thu nhập. ";
					}
					echo($nametemp); ?>
                    <td>
                </tr>
                <tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Số tiền cho vay</span></td>
                    <td align="center"><?php echo(changnumbermoney($arrload[0][5])) ?> VNĐ - <?php echo(changnumbermoney($arrload[0][6])) ?> VNĐ<td>
                </tr>
                <tr>
            		<td  style="background: #F1F1F1;"align="left" width="200px"><span style="margin-left: 20px;">Lãi suất</span></td>
                    <td  style="background: #F1F1F1;"align="center"><?php echo($arrload[0][9]) ?>%/năm - <?php echo($arrload[0][10]) ?>%/năm<td>
                </tr>
                <tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Thu nhập hàng tháng</span></td>
                    <td align="center"><?php echo($arrload[0][7]) ?> triệu đồng<td>
                </tr>
                <tr>
            		<td style="background: #F1F1F1;" align="left" width="200px"><span style="margin-left: 20px;">Hinhg thức trả lương</span></td>
                    <td style="background: #F1F1F1;" align="center"><?php $hinhthuctraluong = "Tiền mặt";
						if($arrload[0][8] == "2") {
							$hinhthuctraluong = "Chuyển khoản";
						}
						echo($hinhthuctraluong); ?><td>
                </tr>
                <tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Loại lãi suất</span></td>
                    <td align="center"><?php $arrtyperate = explode(',', $arrload[0][11]); foreach($arrtyperate as $entry) {
	if($entry == "1") {
		echo("Lãi suất dư nợ giảm dần. <br>");
	} else {
		echo("Lãi suất dư nợ ban đầu. <br>");
	}
} ?><td>
                </tr>
                <tr>
            		<td style="background: #F1F1F1;" align="left" width="200px"><span style="margin-left: 20px;">Thời gian vay</span></td>
                    <td style="background: #F1F1F1;" align="center"><?php echo($arrload[0][12]) ?> năm<td>
                </tr>
                <tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Phí tất toán</span></td>
                    <td align="center"><?php echo($arrload[0][13]) ?><td>
                </tr>
                <tr>
            		<td  style="background: #F1F1F1;"align="left" width="200px"><span style="margin-left: 20px;">Khu vực</span></td>
                    <td  style="background: #F1F1F1;"align="center"><?php echo($arrload[0][14]) ?><td>
                </tr>
                <tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Tất Toán Trước Hạn</span></td>
                    <td align="center"><?php if($arrload[0][15] == "cophi") { echo("Có Phí"); }else {echo("Không Phí");} ?><td>
                </tr>
                <tr>
            		<td  style="background: #F1F1F1;"align="left" width="200px"><span style="margin-left: 20px;">Nhà cung cấp</span></td>
                    <td  style="background: #F1F1F1;"align="center"><?php $tochuc = "Ngân hàng";
		if($arrload[0][16] == "phibank") {
			$tochuc = "Công Ty Tài Chính";
		} echo($tochuc); ?><td>
                </tr>
                <tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Thanh toán hàng tháng</span></td>
                    <td align="center"><?php echo(changnumbermoney(round($arrload[0][5] * $arrload[0][9] / 12 / 100, -3))." VNĐ"); ?> - <?php echo(changnumbermoney(round($arrload[0][6] * $arrload[0][10] / 12 / 100, -3))." VNĐ"); ?><td>
                </tr>
                <tr>
            		<td  style="background: #F1F1F1;"align="left" width="200px"><span style="margin-left: 20px;">Thông tin khoản vay tối đa</span></td>
                    <td  style="background: #F1F1F1;"><div style="margin-left: 5px; margin-right: 5px;"><?php echo($arrload[0][17]) ?></div><td>
                </tr>
                <tr>
            		<td align="left" width="200px"><span style="margin-left: 20px;">Điều kiện cơ bản</span></td>
                    <td><div style="margin-left: 5px; margin-right: 5px;"><?php echo($arrload[0][18]) ?></div><td>
                </tr>
            </table>
        </div>
    </div>
	
    <div style="float: right; clear: right; background-image: url(<?php echo($host) ?>images/gray_bg.gif); width: 275px; height: auto; margin-top: 10px;">
        <?php include("formsendapplyloan.php"); ?>
    </div>
</div>
<?php
	}
}
?>